package com.wn.ziroombackend.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wn.ziroombackend.entity.Incomeorder;
import com.wn.ziroombackend.mapper.IncomeorderMapper;
import com.wn.ziroombackend.service.IncomeorderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wn.ziroombackend.vo.IncomeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wangzhijia
 * @since 2023-02-27 10:56:29
 */
@Service
public class  IncomeorderServiceImpl extends ServiceImpl<IncomeorderMapper, Incomeorder> implements IncomeorderService {
    @Autowired
    private IncomeorderMapper incomeorderMapper;

    @Override
    public PageInfo<IncomeVo> getIncomeList(Integer num, Integer size, String quartersName, String ownerName, int status) {
        PageHelper.startPage(num,size);
        List<IncomeVo> List=incomeorderMapper.selectByPage(quartersName,ownerName,status);
        return new PageInfo<IncomeVo>(List);

    }

    @Override
    public void updateStatusById(Incomeorder incomeorder) {
        incomeorderMapper.updateByid(incomeorder.getId());
    }

    @Override
    public List<Incomeorder> selectall() {
        QueryWrapper<Incomeorder> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("status",0);
        return incomeorderMapper.selectList(queryWrapper);
    }

    @Override
    public void updateByids(int i) {
        incomeorderMapper.updateByid(i);
    }
}
